package com.steptime.product.controller;

import com.steptime.api.RemoteUserCenterService;
import com.steptime.model.Product;
import com.steptime.model.User;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@RequestMapping(" ")
public class ProductController {

  @LoadBalanced
  @Bean
  public RestTemplate restTemplate() {
    return new RestTemplate();
  }
  @Autowired
  private DiscoveryClient discoveryClient;
  @Autowired
  private RestTemplate restTemplate;

  @Autowired
  private RemoteUserCenterService remoteUserCenterService;

  @GetMapping
  public List<Product> list(){
    List products = new ArrayList();
    products.add(new Product());

    return products;
  }

  @GetMapping("/user")
  public List<User> userList(){
    return remoteUserCenterService.list();
  }

  @GetMapping("test")
  public List test(){
    return remoteUserCenterService.list();
    // return restTemplate.getForObject("http://trans-user-center/users",List.class);
   /* return discoveryClient.getInstances("trans-user-center");*/
  }
}
